/**
 * @author 徐楠
 * @date 2022/5/1 22:13
 * @version 1.0
 */

package com.xunan.likou;

import java.util.ArrayList;
import java.util.List;

public class FizzBuzzTest {
    public static void main(String[] args) {
        List<String> list = fizzBuzz(5);
        System.out.println(list);
    }

    public static List<String> fizzBuzz(int n) {
        List<String> list = new ArrayList<>();
        boolean judge1 = false;
        boolean judge2 = false;
        for (int i = 1; i <= n; i++) {
            if (i % 3 == 0) {
                judge1 = true;
            }
            if (i % 5 == 0) {
                judge2 = true;
            }

            if (judge1 && judge2) {
                list.add("FizzBuzz");
            } else if (judge1) {
                list.add("Fizz");
            } else if (judge2) {
                list.add("Buzz");
            } else {
                list.add(i + "");
            }

            judge1 = false;
            judge2 = false;
        }
        return list;

    }
}
